import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import { routerRedux, Link } from 'dva/router';
import moment from 'moment';
import {
    Row, Col, Card, Form, Input,
    Select, Icon, Button, Dropdown, Menu,
    InputNumber, DatePicker, Modal, message,
    Badge, Divider, Tag, Table
} from 'antd';
import StandardTable from '../../components/StandardTable';
import PageHeaderLayout from '../../layouts/PageHeaderLayout';

import styles from './PendingTask.less';

const FormItem = Form.Item;
const { Option } = Select;
const { MonthPicker, RangePicker } = DatePicker;
/*
  审批管理的待办任务界面
*/

@connect(({ pendingTask }) => ({
    pendingTask,
}))
@Form.create()
export default class PendingTask extends PureComponent {
    state = {
       
    };
    componentDidMount() {
        const { dispatch } = this.props;
        dispatch({
          type: 'pendingTask/fetch',
          payload: { offset: 0, limit: 10 ,state: 1},
        });
      }
    
      handleStandardTableChange = (e) => {
        const { dispatch } = this.props;
        dispatch({
          type: 'pendingTask/fetch',
          payload: { offset: (e.current - 1) * e.pageSize, limit: e.pageSize ,state: 1},
        });
    
      }
 
    columns = [{
        title: '业务编号',
        dataIndex: 'bizNum',
        key: 'bizNum',
    }, {
        title: '客户名称',
        dataIndex: 'custName',
        key: 'custName',
    }, {
        title: '担保机构名称',
        dataIndex: 'orgName',
        key: 'orgName',
    }, {
        title: '贷款金额',
        dataIndex: 'amount',
        key: 'amount',
    }, {
        title: '上报时间',
        dataIndex: 'createTime',
        key: 'createTime',
    }, {
        title: '目前任务',
        dataIndex: 'taskName',
        key: 'taskName',
    }, {
        title: '操作',
        render: (text, record) => (
            <Fragment>
                <Link to={`/review/apply-details/step1?id=${record.id}&state=1`}>审批</Link>
            </Fragment>
        ),
    }];

    render() {
        const { pendingTask: { pendingList, page , loading }} = this.props;

        return (
            <PageHeaderLayout title="待办任务">
                <Card bordered={false}>
                    <div className={styles.tableList}>
                        <Table
                            columns={this.columns}
                            dataSource={pendingList}
                            bordered
                            rowKey="id"
                            pagination={page}
                            loading={loading}
                            onChange={this.handleStandardTableChange}
                        />
                    </div>
                </Card>
            </PageHeaderLayout>
        );
    }
}
